import { UserProfilesAPI } from "../../request/api";
export default {
    namespaced: true,
    state: {
        // 控制模态框显示隐藏
        userInfo: {
            nickName: "name",
            coin: 10,
            headImg: require("../../assets/img/userImg.f8bbec5e.png")
        },
        cartTotal: 0
    },
    mutations: {
        // 修改控制模态框开关
        changeUserInfo(state, payload) {
            console.log("userInfo");
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        // 初始化
        initUserInfo(state) {
            state.userInfo = {
                nickName: "name01",
                coin: 0,
                headImg: require("../../assets/img/userImg.f8bbec5e.png")
            }
            state.cartTotal = 0
        }
    },
    actions: {
        async asyncChangeUserInfo(context, payload) {
            let user = await UserProfilesAPI()
            context.commit("changeUserInfo", user.data)
        }
    }
}